package db.seed;

import com.mai4j.maiadmin.setup.Helper;
import lombok.extern.slf4j.Slf4j;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;

import java.time.LocalDateTime;

import static com.mai4j.maiadmin.generated.Tables.LANGUAGE;
import static org.jooq.impl.DSL.using;

/**
 * 初始化的语言
 */
@Slf4j
public class V20230404162124__Insert_Language extends BaseJavaMigration {

    @Override
    public void migrate(Context context) {
        using(context.getConnection())
                .insertInto(LANGUAGE)
                .columns(
                        LANGUAGE.LANGUAGE_ID,
                        LANGUAGE.LANGUAGE_CODE,
                        LANGUAGE.NAME,
                        LANGUAGE.SORT_ORDER,
                        LANGUAGE.STATUS,
                        LANGUAGE.DATE_ADDED,
                        LANGUAGE.DATE_MODIFIED)
                .values(Helper.next(), "zh-CN", "简体中文", 0, (byte) 1, LocalDateTime.now(), LocalDateTime.now())
                .values(Helper.next(), "en-US", "English", 1, (byte) 1, LocalDateTime.now(), LocalDateTime.now()).execute();
    }
}
